package operator;

import book.BookList;

import java.util.Scanner;

/**
 * Version: 1.1
 * Author: TangJun
 * Date: 2024-07-18
 */
public class BorrowOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("开始借阅图书");
        System.out.println("请输入你要借的书籍名字");
        Scanner scan = new Scanner(System.in);
        String name = scan.next();

        int index = findIndex(bookList, name);
        if (index >= 0 && !(bookList.getPos(index).isBorrowed())) {
            bookList.getPos(index).setBorrowed(true);
            System.out.println("借阅成功");
            return;
        }
        System.out.println("没有这本书，借不了");
    }
}
